package com.scanner;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;

public class ButtonView extends View {

	private Paint ballPaint = new Paint();
	private CenterButton buttonModel;

	public ButtonView(Context context, Context context2)
	{
		super(context);
		ballPaint.setStrokeWidth(2);
		ballPaint.setARGB(120, 0, 250, 120);
		setWillNotDraw(false);
	}
	
	public ButtonView(Context context, CenterButton button) {
		super(context);

		buttonModel = button;
		
		ballPaint.setStrokeWidth(2);
		setPaintColor();
		setWillNotDraw(false);
		
	}

	private void setPaintColor()
	{
		if (buttonModel.isStateEnabled() == true )
		{
			ballPaint.setARGB(120, 0, 250, 120);
		}
		else
		{
			ballPaint.setARGB(120, 250, 0, 120);
		}
	}
	
	@Override
	public void onDraw(Canvas canvas) {
		// Drawing the ball
		setPaintColor();
		int x = buttonModel.getButtonX();
		int y = buttonModel.getButtonY();
		canvas.drawCircle(x, y, buttonModel.getRadius(), ballPaint);
	}

}
